﻿#include "CSocketMisc.h"


int csocketmisc_send_buff(SOCKET* s, void* buff, int size) {
	int sended = 0;
	int ret = 0;
	while (sended < size) {
		ret = send(*s, (char*)buff + sended, size - sended, 0);
		if (SOCKET_ERROR == ret) {
			return -1;
		}
		sended += ret;
	}
	return 0;
}

int csocketmisc_send_msg(SOCKET* s, CMsg* msg) {
	csocketmisc_send_buff(s, msg, msg->data_len + sizeof(CMsg));
	return 0;
}